<template>
  <div>
    <el-dialog v-bind="$attrs" v-on="$listeners" @open="onOpen" @close="onClose" title="Dialog Titile">
      <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px">
        <el-form-item label="数据库类型" prop="mobile">
          <el-select v-model="formData.mobile" placeholder="请选择数据库类型" clearable :style="{width: '100%'}">
          </el-select>
        </el-form-item>
        <el-form-item label="服务器名称" prop="field102">
          <el-input v-model="formData.field102" placeholder="请输入服务器名称" clearable :style="{width: '100%'}">
          </el-input>
        </el-form-item>
        <el-form-item label="端口号" prop="field103">
          <el-input v-model="formData.field103" placeholder="请输入端口号" clearable :style="{width: '100%'}">
          </el-input>
        </el-form-item>
        <el-form-item label="数据库名称" prop="field104">
          <el-input v-model="formData.field104" placeholder="请输入数据库名称" clearable :style="{width: '100%'}">
          </el-input>
        </el-form-item>
        <el-form-item label="数据库用户名" prop="field105">
          <el-input v-model="formData.field105" placeholder="请输入数据库用户名" clearable :style="{width: '100%'}">
          </el-input>
        </el-form-item>
        <el-form-item label="数据库用户名" prop="field106">
          <el-input v-model="formData.field106" placeholder="请输入数据库用户名" clearable :style="{width: '100%'}">
          </el-input>
        </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button @click="close">取消</el-button>
        <el-button type="primary" @click="handelConfirm">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
export default {
  inheritAttrs: false,
  components: {},
  props: [],
  data() {
    return {
      formData: {
        mobile: undefined,
        field102: undefined,
        field103: undefined,
        field104: undefined,
        field105: undefined,
        field106: undefined,
      },
      rules: {
        mobile: [{
          required: true,
          message: '请选择数据库类型',
          trigger: 'change'
        }, {
          pattern: /^1(3|4|5|7|8|9)\d{9}$/,
          message: '手机号格式错误',
          trigger: 'change'
        }],
        field102: [{
          required: true,
          message: '请输入服务器名称',
          trigger: 'blur'
        }],
        field103: [{
          required: true,
          message: '请输入端口号',
          trigger: 'blur'
        }],
        field104: [{
          required: true,
          message: '请输入数据库名称',
          trigger: 'blur'
        }],
        field105: [{
          required: true,
          message: '请输入数据库用户名',
          trigger: 'blur'
        }],
        field106: [{
          required: true,
          message: '请输入数据库用户名',
          trigger: 'blur'
        }],
      },
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    onOpen() {},
    onClose() {
      this.$refs['elForm'].resetFields()
    },
    close() {
      this.$emit('update:visible', false)
    },
    handelConfirm() {
      this.$refs['elForm'].validate(valid => {
        if (!valid) return
        this.close()
      })
    },
  }
}

</script>
<style>
</style>
